Problem populating "ResourceCustom" attribute with import-csv
I am trying to script population of the "ResourceCustom" attribute on my conference room mailboxes. I have a csv with the relevant field populated but I think the double-quotes inside my CSV are messing up the import. The powershell line looks like: import-csv c:\confroomsdetails.csv | foreach {Set-Mailbox -Identity $_.DisplayName -ResourceCustom $_.Resources} the raw csv looks like this: Name,DisplayName,ResourceCapacity,Resources,Location,BusinessPhone "Confroom, Omega (6)",Confroom, Omega (6)",6,"Whiteboard,ConferencePhone","Third Floor, West Wing",555-555-1234 the error i get is: Set-Mailbox : The resource search property value "Whiteboard,ConferencePhone" is not valid. At line:1 char:83 + import-csv "c:\confroomsdetails.csv" | foreach {Set-Mailbox <<<< -Identity $_.DisplayName -ResourceCustom $_.Resources} If I manually run the set-mailbox command and enter "-ResourceCustom Whiteboard,ConferencePhone" then it works. Still coming up to speed on Powershell. Any help would be appreciated
May 14th, 2009 12:38am

Hi, We can export the Resource mailbox to a CSV file and find that the value for ResourceCustom is Microsoft.Exchange.Data.MultiValuedProperty`1[System.String] which is the value for ResourcePropertySchema. I have tested the issue and found that if we have multiple value on ResourceCustom in CSV, it will recognize it as one whole value which we have not set in Resoure configuration. 1. When we change Microsoft.Exchange.Data.MultiValuedProperty`1[System.String] as WhiteBoard(single value with out ConferencePhone) and then import the CSV. 2. Using Get-mailbox indentity Confroom Omega(6) |fl and check the value on ResourceCustom has been changed to WhiteBoard. So as a workaround, we can set different Resource Configuration as below: $ResourceConfiguration = Get-ResourceConfig $ResourceConfiguration.ResourcePropertySchema+=("Room/ Whiteboard ") $ResourceConfiguration.ResourcePropertySchema.Add("Room/ConferencePhone") $ResourceConfiguration.ResourcePropertySchema+=("Room/WhiteboardConferencePhone") Set-ResourceConfig -Instance $ResourceConfiguration Regards, Xiu
Free Windows Admin Tool Kit Click here and download it now
May 15th, 2009 12:08pm

Xiu, Interesting workaround. I will have to think about this but the original problem perplexes me for some reason. I can manually run a line of text for one conference room and I can add multiple resource descriptions. set-mailbox Room123 -ResourceCustom Whiteboard,ConferencePhone That works! I just can't do that when piping from an Import-csv OR there is some magical syntaxing that I may need to do to ignore the double quotes around the resources. I will probably just make an excel concatenate formula that will make a 100 line powershell batch file.... Thanks for checking
May 18th, 2009 6:40pm

Hey, I can see a missingquote symbolein second value, DisplayName, which might be causing failuer at the identity of Set-Mailbox in your syntax. Add quote sign in csv file and run the cmdlet with import-csv again... Name,DisplayName,ResourceCapacity,Resources,Location,BusinessPhone"Confroom, Omega (6)","Confroom, Omega (6)",6,"Whiteboard,ConferencePhone","Third Floor, West Wing",555-555-1234 Amit Tank | MVP Exchange Server | MCITP:EMA MCSA:M | http://ExchangeShare.WordPress.com
Free Windows Admin Tool Kit Click here and download it now
May 18th, 2009 8:13pm

Hey, I can see a missingquote symbolein second value, DisplayName, which might be causing failuer at the identity of Set-Mailbox in your syntax. Add quote sign in csv file and run the cmdlet with import-csv again... Name,DisplayName,ResourceCapacity,Resources,Location,BusinessPhone "Confroom, Omega (6)"," Confroom, Omega (6)",6,"Whiteboard,ConferencePhone","Third Floor, West Wing",555-555-1234 Amit Tank | MVP Exchange Server | MCITP:EMA MCSA:M | http://ExchangeShare.WordPress.com Amit, The file actually has it. I just chopped it accidentally when changing the name to a made-up one.
May 18th, 2009 8:23pm

Looks like Xiu is correct. ~ When we pass the values in single cmdlet without import-csv it passes as an array (set of two different strings, one is whiteboard and second conferencephone). ~ While passing it through csv file it consider it as a single string "whiteboard,conferencephone" and it fails because it is not predefined custom resources. Another kind of workaround is split values to two different string and pass those to set-mailbox cmdlet... CSV file: Name,DisplayName,ResourceCapacity,Resource1,Resource2,Location,BusinessPhone"Confroom, Omega (6)","Confroom, Omega (6)",6,Whiteboard,ConferencePhone,"Third Floor, West Wing",555-555-1234 Cmdlet: import-csv c:\test.csv | foreach { $r1=$_.resource1; $r2=$_.resource2;Set-Mailbox -Identity $_.Name -ResourceCustom $r1,$r2} Amit Tank | MVP Exchange Server | MCITP:EMA MCSA:M | http://ExchangeShare.WordPress.com
Free Windows Admin Tool Kit Click here and download it now
May 18th, 2009 9:09pm

Amit, That worked like a charm. I split the values into strings and then called them with your example as a guide. Thanks a bunch! -A
May 27th, 2009 5:49am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics